import {
  AutomationActionStepId,
  AutomationFeature,
  AutomationIOType,
  AutomationStepDefinition,
  AutomationStepType,
  ContentType,
  PrettyContentTypes,
} from "@budibase/types"

export const definition: AutomationStepDefinition = {
  name: "Generate Text",
  icon: "Edit",
  tagline: "Generate contentusing AI",
  description:
    "Uses AI to generate text content based on your instructions and chosen format",
  stepId: AutomationActionStepId.GENERATE_TEXT,
  internal: true,
  inputs: {
    contentType: ContentType.DOCUMENT,
  },
  features: {
    [AutomationFeature.LOOPING]: true,
  },
  schema: {
    inputs: {
      properties: {
        contentType: {
          type: AutomationIOType.STRING,
          title: "Content type",
          enum: Object.values(ContentType),
          pretty: Object.values(PrettyContentTypes),
        },
        instructions: {
          type: AutomationIOType.LONGFORM,
          title: "Instructions",
          description:
            "Provide guidance to help the AI produce content in the format that you want",
        },
      },
      required: ["contentType", "instructions"],
    },
    outputs: {
      properties: {
        generatedText: {
          type: AutomationIOType.STRING,
          description: "The text content generated by the AI",
        },
        success: {
          type: AutomationIOType.BOOLEAN,
          description: "Whether the text generation was successful",
        },
      },
      required: ["generatedText", "success"],
    },
  },
  type: AutomationStepType.ACTION,
}
